package imp.core.control;

import imp.core.data.SessionData;
import imp.core.debug.DebugManager;


/**
 * This class is used to exit the program.
 * @author Patrick Arnold
 * @since 09.09.2010
 *
 */
public class Exit {
	
	/**
	 * The method to properly exit the program. 
	 * @param userDefined Specifies whether exiting the program is user-defined or not (in
	 * this case the exiting was forced by a severe error).
	 */
	public static void exit( boolean userDefined) {
		
		if( SessionData.isDebugMode()) {
			
			String exitType = "user-defined";
			if( !userDefined) {
				exitType = "severe error";
			}
			
			String[] output = new String[1];
			output[0] = "Exiting the program: " + exitType;
			
			DebugManager.displayStringField( output, "Exiting Program");
			
		}
		
		
		System.exit(0);
		
	}

}
